The MessageUI namespace provides functions to detect messaging capabilities and present a system message compose view from within a script. You can send SMS or MMS messages with optional subject and attachments, depending on device capabilities.
MessageUI.isAvailable: booleanReturns true if the device is capable of sending plain text messages.
MessageUI.canSendSubject: booleanReturns true if the device supports adding a subject to messages.
MessageUI.canSendAttachments: booleanReturns true if the device supports including attachments in messages.
MessageUI.present(options): Promise<"cancelled" | "sent" | "failed">Displays the system’s message composer with the specified content and resolves with the result of the user’s action.
| Name | Type | Required | Description |
|---|---|---|---|
recipients |
string[] |
Yes | An array of recipient phone numbers. |
body |
string |
Yes | The text content of the message body. |
subject |
string |
No | Optional subject line. Ignored if canSendSubject is false. |
attachments |
Attachment[] |
No | Optional list of attachments. Ignored if canSendAttachments is false. |
Each item in the attachments array must include:
| Property | Type | Required | Description |
|---|---|---|---|
data |
Data |
Yes | The binary data to be attached to the message. |
type |
UTType |
Yes | A Uniform Type Identifier string, such as "public.image" or "public.text". |
fileName |
string |
Yes | The name that will appear for the attachment in the message. |
Returns a Promise that resolves to one of the following values:
"sent": The message was successfully sent by the user."cancelled": The user canceled the message."failed": The message failed to send due to an error (e.g., connectivity or system failure).subject and attachments options are automatically ignored if not supported on the device.